﻿using SRB.Tg.DrawingStandard;
using SRB.Tg.Operate;
using System;
using System.Collections.Generic;
using System.Data;
using Teigha.DatabaseServices;
using Teigha.Geometry;

namespace SRB.Tg.Model
{
    public class PileCapInfo
    {
        DataRow dr;
        string configure_name = "", reinforcement_grade = "", concrete_no="";
        public double length, width, height;
        public double around_l_reinforcement_diameter,
           around_reinforcement_spacing,
           around_w_reinforcement_diameter,
           around_h_reinforcement_diameter,
           around_h_reinforcement_spacing,
           bottom_l_reinforcement_diameter,
           bottom_l_reinforcement_spacing,
           bottom_reinforcement_layers_number,
           bottom_reinforcement_layers_spacing,
           bottom_w_reinforcement_diameter,
           bottom_w_reinforcement_spacing,
           concrete_protect_layer,
           erection_reinforcement_diameter,
           erection_reinforcement_l_spacing,
           erection_reinforcement_w_spacing,
           top_l_reinforcement_diameter,
           top_l_reinforcement_spacing,
           top_reinforcement_layers_number,
           top_reinforcement_layers_spacing,
           top_w_reinforcement_diameter,
           top_w_reinforcement_spacing,
           cushion_cornice_length,
           cushion_thickness;
        public string pile_diameter,
           pile_layout,
           pier_type,
           pier_size,
           pier_layout;
        public string[] pierSize =null;
        public string[] pierLocation = null;

        public string[] pileSize = null;
        public string[] pileLocation = null;
        List<Tuple<int,eSampleType, eDB, int, double>> rebarLst = new List<Tuple<int, eSampleType, eDB, int, double>>();

        double radius = 1;
        public PileCapInfo(DataRow row)
        {
            dr = row;
            configure_name = dr["configure_name"].ToString();
            reinforcement_grade = dr["reinforcement_grade"].ToString();
            concrete_no= dr["concrete_no"].ToString();
            length = double.Parse(dr["length"].ToString());
            width = double.Parse(dr["width"].ToString());
            height = double.Parse(dr["height"].ToString());
           
            around_l_reinforcement_diameter = double.Parse(dr["around_l_reinforcement_diameter"].ToString());
            around_reinforcement_spacing = double.Parse(dr["around_reinforcement_spacing"].ToString());
            around_w_reinforcement_diameter = double.Parse(dr["around_w_reinforcement_diameter"].ToString());
            around_h_reinforcement_diameter = double.Parse(dr["around_h_reinforcement_diameter"].ToString());
            around_h_reinforcement_spacing = double.Parse(dr["around_h_reinforcement_spacing"].ToString());
            bottom_l_reinforcement_diameter = double.Parse(dr["bottom_l_reinforcement_diameter"].ToString());
            bottom_l_reinforcement_spacing = double.Parse(dr["bottom_l_reinforcement_spacing"].ToString());
            bottom_reinforcement_layers_number = double.Parse(dr["bottom_reinforcement_layers_number"].ToString());
            bottom_reinforcement_layers_spacing = double.Parse(dr["bottom_reinforcement_layers_spacing"].ToString());
            bottom_w_reinforcement_diameter = double.Parse(dr["bottom_w_reinforcement_diameter"].ToString());
            bottom_w_reinforcement_spacing = double.Parse(dr["bottom_w_reinforcement_spacing"].ToString());
            concrete_protect_layer = double.Parse(dr["concrete_protect_layer"].ToString());
            erection_reinforcement_diameter = double.Parse(dr["erection_reinforcement_diameter"].ToString());
            erection_reinforcement_l_spacing = double.Parse(dr["erection_reinforcement_l_spacing"].ToString());
            erection_reinforcement_w_spacing = double.Parse(dr["erection_reinforcement_w_spacing"].ToString());
            top_l_reinforcement_diameter = double.Parse(dr["top_l_reinforcement_diameter"].ToString());
            top_l_reinforcement_spacing = double.Parse(dr["top_l_reinforcement_spacing"].ToString());
            top_reinforcement_layers_number = double.Parse(dr["top_reinforcement_layers_number"].ToString());
            top_reinforcement_layers_spacing = double.Parse(dr["top_reinforcement_layers_spacing"].ToString());
            top_w_reinforcement_diameter = double.Parse(dr["top_w_reinforcement_diameter"].ToString());
            top_w_reinforcement_spacing = double.Parse(dr["top_w_reinforcement_spacing"].ToString());
            cushion_cornice_length = double.Parse(dr["cushion_cornice_length"].ToString());
            cushion_thickness = double.Parse(dr["cushion_thickness"].ToString());

            pile_diameter = dr["pile_diameter"].ToString();
            pileSize = pile_diameter.Split(';');
            pile_layout = dr["pile_layout"].ToString();
            pileLocation = pile_layout.Split(';');
            pier_type = dr["pier_type"].ToString();
            pier_size = dr["pier_size"].ToString();
            pierSize = pier_size.Split(';');
            pier_layout = dr["pier_layout"].ToString();
            pierLocation= pier_layout.Split(';');
        }
        public void DrawingPileCap(Database db, int OverAllScale)
        {

            #region 绘制图形
            Extents2d ExtPileCap1, ExtPileCap2, ExtPileCap3, ExtPileCap4, ExtPileCap5, ExtCal,ExtRefer; 
            Point2d RefPtPileCap1, RefPtPileCap2, RefPtPileCap3, RefPtPileCap4, RefPtPileCap5,RefPtCal, RefPt;
            RefPtPileCap1 = Point2d.Origin;

            PlotElevationA(ref db, out ExtPileCap1, RefPtPileCap1, OverAllScale);

            RefPtPileCap2 = Point2d.Origin.C2D(ExtPileCap1.W() + 10 * OverAllScale);
            PlotElevationB(ref db, out ExtPileCap2, RefPtPileCap2, OverAllScale);

            RefPtPileCap3 = Point2d.Origin.C2D(0, -ExtPileCap1.L() - 10 * OverAllScale);
            PlotElevationC(ref db, out ExtPileCap3, RefPtPileCap3, OverAllScale);

            RefPtPileCap4 = Point2d.Origin.C2D(ExtPileCap3.W()+10 * OverAllScale, -ExtPileCap1.L() - 10 * OverAllScale);
            PlotElevationD(ref db, out ExtPileCap4, RefPtPileCap4, OverAllScale);

            RefPtPileCap5 = Point2d.Origin.C2D(ExtPileCap3.W() + ExtPileCap4.W() + 20 * OverAllScale, -ExtPileCap1.L() - 10 * OverAllScale);
            PlotElevationE(ref db, out ExtPileCap5, RefPtPileCap5, OverAllScale);
            //PlotElevationB(ref db, out ExtPileCap2, RefPtPileCap2, OverAllScale);

            #endregion
            CalculateRebar();
            RefPtCal = RefPtPileCap2.C2D(ExtPileCap2.W() * 1.1);
            ExtCal = new Extents2d(RefPtCal, RefPtCal);
            PlotCalculate(ref db, ref ExtCal, RefPtCal, 1);

        
            RefPt = RefPtCal.C2D(ExtCal.W() * 1.1);
            ExtRefer = new Extents2d(RefPt, RefPt);
            PlotRefer(ref db, ref ExtRefer, RefPt, 1);
            #region 模型空间到布局空间投影处理
            Point2d tKPoint = Point2d.Origin;
            LayoutTools.CreateSerPileCapLayout(db, "图纸", ExtPileCap1, ExtPileCap2, ExtPileCap3, ExtPileCap4, ExtPileCap5, ExtCal, ExtRefer, Extensions.leftWidth, Extensions.rightWidth, Extensions.bottomHeight, Extensions.topHeight, 5, ref tKPoint);
            string dwgPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\RebarSerbia.dwg";
            string _blcName = "TK";
            BlockPlot.InsertBlockToPaperByDwg(db, dwgPath, _blcName, "H钢筋", tKPoint.C3D(), 1, 0, true, false);

            // 文字         
            string text = @"ПРОЈЕКАТ ПРИЛАЗНИХ КОНСТРУКЦИЈА-M09 (KM1+109.500~KM1+191.500)";
            Point3d p0 = tKPoint.C3D(-185+44.7,38);
            Extents2d ext = new Extents2d();
            TextPloter.AddMText2Paper(db,p0, ref ext, text, 1, 2, 120, Extensions.curFont);
            string text1 = @"DESIGN OF APPROACH BRIDGE-M09 (KM1+109.500~KM1+191.500) ";
            Point3d p1 = tKPoint.C3D(-185 + 44.7, 38-3);
            TextPloter.AddMText2Paper(db,p1, ref ext, text1, 1, 2, 120, Extensions.curFont);

            string text2 = @"356-PGD-2/1.3.9";
            Point3d p2 = tKPoint.C3D(-185 + 153, 30);
            TextPloter.AddMText2Paper(db,p2, ref ext, text2, 1, 2.2, 40, Extensions.curFont);
            string text3 = @"1:" + OverAllScale * 10; 
            Point3d p3 = tKPoint.C3D(-185 + 153, 20);
            TextPloter.AddMText2Paper(db,p3, ref ext, text3, 1, 2.2, 40, Extensions.curFont);
            #endregion
        }

        private void PlotCalculate(ref Database db, ref Extents2d ext, Point2d insertPoint, int scale = 1)
        {
            ext = new Extents2d(insertPoint, insertPoint);
            //TextPloter.AddTitleS(db,insertPoint, ref ext, "PILE REINFORCEMENT PLAN", @"ПЛАН АРМАТУРЕ ШИПОВАПИ", "(1:" + _scale + ")", scale);
            Point3d ptTable = insertPoint.C3D();
            double volumn = Math.Ceiling(length * 0.01 * width * 0.01 *  height * 0.01);
            double height0 = 0;
            double width0 = 0;
            List<Tuple<eDB, int, double>> rebarList;
            ModelTablePloter.DrawPileCapCalNewTable(db, ref ext, ptTable, ref height0, ref width0, Extensions.curFont, scale, rebarLst, reinforcement_grade, volumn,out rebarList);
            List<eDB> newList = new List<eDB>();
            rebarList.ForEach(i => {
                if (!newList.Contains(i.Item1))
                {
                    newList.Add(i.Item1);
                }
            });
            ModelTablePloter.DrawPileCapCalMergeTable(db, ref ext, ptTable.C3D(0,-height0-5), ref height0, ref width0, Extensions.curFont, scale, rebarList, newList, reinforcement_grade,concrete_no, volumn, out rebarList);
        }

        private void PlotRefer(ref Database db, ref Extents2d ext, Point2d insertPoint, int scale = 1)
        {
            string dwgPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Template\\RebarSerbia.dwg";

            ext = new Extents2d(insertPoint, insertPoint);

            Point3d ptD = insertPoint.C3D();
            //ext = new Extents2d(insertPoint, insertPoint);
            string _blcName = "ReferPileCapTb";
            BlockPlot.InsertBlockByDwg(db, dwgPath, _blcName, "H钢筋", ptD, ref ext, scale, 0, true, false);

            ptD = insertPoint.C3D(0, -ext.L()-5);
            //ext = new Extents2d(insertPoint, insertPoint);
            _blcName = "ReferTb";
            BlockPlot.InsertBlockByDwg(db, dwgPath, _blcName, "H钢筋", ptD, ref ext, scale, 0, true, false);

            ptD = insertPoint.C3D(0, -ext.L() - 5);
            //ext = new Extents2d(insertPoint, insertPoint);
            _blcName = "ReferScale";
            BlockPlot.InsertBlockByDwg(db, dwgPath, _blcName, "H钢筋", ptD, ref ext, scale, 0, true, false);
            // 文字         
            string   text = @"
     Note: If the length of the dimension is greater than 10m, it is counted as m,   and if the length is less\\P than 10m, it is counted as cm.";
            Point3d p2 = insertPoint.C3D(0,-ext.L() - 5);
            TextPloter.AddMText(db,p2, ref ext, text, scale, 2.5, 170 * scale, Extensions.curFont);
        }
        public void PlotElevationA(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
           
              double LA = 0;
            List<Point2d> ptList = new List<Point2d>();
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -60 * scale);

            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitleS(db,insertPoint, ref ext, "CROSS SECTION 1-1", @"ПОПРЕЧНИ ПРЕСЕК 1-1", "Р/SC 1:" + scale * 10 + "", scale);


            //绘制中心线
            PLPloter.AddScaleLine(db, M1.C2D(0, 50 * scale), M1.C2D(0, -height -15*scale), ref ext, "H中心线",scale);

            #region  绘制外轮廓
            double pierLen = 160;
            //墩身
            for (int i=0;i< pierLocation.Length;i++)
            {
                double pSizeLen =double.Parse(pierSize[i].ToString());
                pierLen = pSizeLen+40;
                double pLen = double.Parse(pierLocation[i].ToString());
                PLPloter.AddPloy4(db, M1.C2D(-0.5 * length+ pLen, 40 * scale), 0.5 * pSizeLen, 0.5 * pSizeLen, 40 * scale, ref ext, "HM细线");
                PLPloter.AddLine(db,M1.C2D(-0.5 * length + pLen - pierLen*0.5, 40 * scale), M1.C2D(-0.5 * length + pLen + pierLen * 0.5, 40 * scale), ref ext, "HM细线");
                //墩柱直径标注
                DimPloter.DimAli(db,M1.C3D(-0.5 * length + pLen - pSizeLen * 0.5, 30 * scale), M1.C3D(-0.5 * length + pLen + pSizeLen * 0.5, 30 * scale), M1.C3D(0, 35 * scale), ref ext, scale, "D"+ pSizeLen, Unit.Centimeter, Unit.Centimeter);
            }
            //承台
            PLPloter.AddPloy4(db, M1, 0.5 * length, 0.5 * length, height, ref ext, "HM细线");
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(0.5 * length), M1.C3D(0, 20 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(-0.5 * length,-height), M1.C3D(-0.5 * length-20 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);

            //垫层&&桩基
            Point2d pCushionLeft = M1.C2D(-0.5 * length, -height);
            Point2d pCushionRight = M1.C2D(0.5 * length, -height);
            List<Point2d> middleL = new List<Point2d>();
            for (int i = 0; i < pileLocation.Length; i++)
            {
                List<Point2d> leftL = new List<Point2d>();
                leftL.Add(pCushionLeft);
                leftL.Add(pCushionLeft.C2D(-cushion_cornice_length));
                leftL.Add(pCushionLeft.C2D(-cushion_cornice_length, -cushion_thickness));
                List<Point2d> rightL = new List<Point2d>();
                rightL.Add(pCushionRight);
                rightL.Add(pCushionRight.C2D(cushion_cornice_length));
                rightL.Add(pCushionRight.C2D(cushion_cornice_length, -cushion_thickness));
                if (i == 0)
                {
                    leftL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                    middleL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                  
                }
                else if (i == pileLocation.Length - 1)
                {
                    rightL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                    middleL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                  
                }
                else
                {
                    middleL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                    middleL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                  
                }
                //垫层
                PLPloter.AddPolylineByPointList(db,leftL, ref ext, "HM细线", false);
                PLPloter.AddPolylineByPointList(db, rightL, ref ext, "HM细线", false);

                //桩基
                PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, 0), pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -60 * scale), ref ext, "HM细线");
                PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, 0), pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -60 * scale), ref ext, "HM细线");

                PLPloter.AddUpperArcBreakLine(db, pCushionLeft.C2D(double.Parse(pileLocation[i]),-60 * scale), ref ext, double.Parse(pileSize[i]), "HM细线");
                PLPloter.AddBottomArcBreakLine(db, pCushionLeft.C2D(double.Parse(pileLocation[i]), -70 * scale), ref ext, double.Parse(pileSize[i]), "HM细线");

                PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -70 * scale), pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -100 * scale), ref ext, "HM细线");
                PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -70 * scale), pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -100 * scale), ref ext, "HM细线");
                PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -100 * scale), pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -100 * scale), ref ext, "HM细线");

            }
            //垫层
            for (int i = 0; i < middleL.Count; i++)
            {
                if (i % 2 == 0&&i< middleL.Count-1)
                    PLPloter.AddLine(db,middleL[i], middleL[i + 1], ref ext, "HM细线");
            }


          
            #endregion

            #region 绘制钢筋
            //1# 20 ,4# 20 top   
            //2# 32 3# 32 5# 20 6# 20 bottom
            //1、顶部钢筋
            double tL = erection_reinforcement_diameter * 0.1  + top_l_reinforcement_diameter * 0.1 * 0.5;
            double bL = erection_reinforcement_diameter * 0.1-0.2  + bottom_l_reinforcement_diameter * 0.1 * 0.5;
            Point2d ptTop = M1.C2D(0, -concrete_protect_layer- tL);
            double LT = length - 2*(concrete_protect_layer +around_w_reinforcement_diameter*0.1+top_l_reinforcement_diameter*0.1*0.5);
            double LH =Math.Round(height - concrete_protect_layer * 2-tL-bL,1);
            double diaX = around_w_reinforcement_diameter * 0.1 + top_l_reinforcement_diameter * 0.1*0.5;
            double diaY = top_l_reinforcement_diameter * 0.1 * 0.5+ top_w_reinforcement_diameter * 0.1 * 0.5;
            PLPloter.AddPloy4(db, ptTop.C2D(), 0.5 * LT, 0.5 * LT, LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptTop.C2D(-LT*0.5), radius, length - 2 * concrete_protect_layer, LT, top_l_reinforcement_spacing, diaX, diaY, out ptLst, eDirection.E_BOTTOM);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLst, eDirection.E_TOP, 15 * scale,"HM细线");
            Point3d pttxtT14 = GeTools.MidPoint(ptLst[0], ptLst[ptLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtT14.C3D(-10 * scale, 15 * scale+2.5 * scale), ref ext, ptLst.Count + "%%C" + top_w_reinforcement_diameter + "(t=" + top_w_reinforcement_spacing + ")", "4", scale);

         

   

            //2、底部钢筋
            Point2d ptBotom = ptTop.C2D(0, -LH);

            double diaBX = around_w_reinforcement_diameter * 0.1 + bottom_l_reinforcement_diameter * 0.1*0.5;
            double diaBY = bottom_l_reinforcement_diameter * 0.1 * 0.5 + bottom_w_reinforcement_diameter * 0.1 * 0.5;

            List<Point3d> ptBLst = new List<Point3d>();
            List<Point3d> ptB56Lst = new List<Point3d>();   
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, length, LT, bottom_l_reinforcement_spacing, diaBX, diaBY, out ptBLst, eDirection.E_TOP);
            SteelBarPileCap.CreateLineList(db, ref ext, ptBLst, eDirection.E_BOTTOM, 5 * scale*(bottom_reinforcement_layers_number-1) + 20 * scale + 15 * scale, "HM细线");
            Point3d pttxtB25 = GeTools.MidPoint(ptBLst[0], ptBLst[ptBLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtB25.C3D(-10 * scale, -(5 * scale * (bottom_reinforcement_layers_number - 1) + 20 * scale + 15 * scale) - 2.5 * scale), ref ext, ptBLst.Count + "%%C" + bottom_w_reinforcement_diameter + "(t=" + bottom_w_reinforcement_spacing + ")", "5", scale);

            ptList = new List<Point2d>();
            if (bottom_reinforcement_layers_number>1)
            {
                for(int i=1;i< bottom_reinforcement_layers_number;i++)
                {
                    PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, bottom_reinforcement_layers_spacing * i), ptBotom.C2D(LT * 0.5 - 1, bottom_reinforcement_layers_spacing * i), ref ext, "H钢筋");
                    SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5, bottom_reinforcement_layers_spacing * i), radius, length, LT, bottom_l_reinforcement_spacing, diaBX, diaBY, out ptB56Lst, eDirection.E_TOP);
                    SteelBarPileCap.CreateLineList(db, ref ext, ptB56Lst, eDirection.E_BOTTOM, bottom_reinforcement_layers_spacing * i+20*scale+5*scale*i, "HM细线");
                    ptList.Add(ptBotom.C2D(5*scale, bottom_reinforcement_layers_spacing * i));
                }
                Point3d pttxtB36 = GeTools.MidPoint(ptB56Lst[0], ptB56Lst[ptB56Lst.Count - 1]);
                TextPloter.AddDBTextWithCirle(db,pttxtB36.C3D(-10 * scale, -(bottom_reinforcement_layers_spacing * (bottom_reinforcement_layers_number-1) + 20 * scale + 5 * scale * (bottom_reinforcement_layers_number - 1)) - 2.5 * scale), ref ext, ptB56Lst.Count*2 + "%%C" + bottom_w_reinforcement_diameter + "(t=" + bottom_w_reinforcement_spacing + ")", "6", scale);

            }
            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(5 * scale, -8 * scale), ptList, ref ext, "%%C" + bottom_l_reinforcement_diameter + "(t=" + bottom_l_reinforcement_spacing + ")", "3", "HM细线", eArrowLocation.BT, scale, false);
            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-20 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(-20 * scale, -8 * scale), ptList, ref ext, "%%C" + bottom_l_reinforcement_diameter + "(t=" + bottom_l_reinforcement_spacing + ")", "2", "HM细线", eArrowLocation.BT, scale, false);

      


            //3、侧面钢筋，纵横方向
            Point2d ptLeft = ptBotom.C2D(0, bottom_reinforcement_layers_spacing* bottom_reinforcement_layers_number);
            //左侧
            double diaAX = around_w_reinforcement_diameter * 0.1 * 0.5+around_h_reinforcement_diameter*0.1 * 0.5;
            double diaAY = 0;
            double HL = LH - bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number;

            List<Point3d> ptB78Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptLeft.C2D(-LT * 0.5), radius, height - 2 * concrete_protect_layer - bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number, HL, around_reinforcement_spacing, diaAX, diaAY, out ptB78Lst, eDirection.E_LEFT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptB78Lst, eDirection.E_LEFT, 15 * scale, "HM细线");
            Point3d pttxtB78 = GeTools.MidPoint(ptB78Lst[0], ptB78Lst[ptB78Lst.Count - 1]);
            List<string> lstCi = new List<string>() { "7", "8" };
            TextPloter.AddDBTextWithListCirle(db,pttxtB78.C3D(-15 * scale - 2.5 * scale, -10 * scale), ref ext, ptB78Lst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", lstCi, scale, 2.5,GeTools.DegreeToRadian(90));

            Point2d ptRight = ptLeft.C2D(LT * 0.5);
            List <Point3d> ptB87Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight, radius, height - 2 * concrete_protect_layer - bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number, HL, around_reinforcement_spacing, diaAX, diaAY, out ptB87Lst, eDirection.E_RIGHT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptB87Lst, eDirection.E_RIGHT, 15 * scale, "HM细线");
            Point3d pttxtB87 = GeTools.MidPoint(ptB87Lst[0], ptB87Lst[ptB87Lst.Count - 1]);      
            TextPloter.AddDBTextWithListCirle(db,pttxtB87.C3D(15 * scale + 2.5 * scale, -10 * scale), ref ext, ptB87Lst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", lstCi, scale, 2.5, GeTools.DegreeToRadian(90));

            ptList = new List<Point2d>();
            //侧面竖立方向
            int numErection = (int)(LT / erection_reinforcement_l_spacing);
            for (int i = 1; i <= numErection; i++)
            {
                PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + erection_reinforcement_l_spacing*i, erection_reinforcement_diameter * 0.1), ptBotom.C2D(-LT * 0.5 + erection_reinforcement_l_spacing * i, -erection_reinforcement_diameter * 0.1), ref ext, "H钢筋");
                ptList.Add(ptTop.C2D(-LT * 0.5 + erection_reinforcement_l_spacing * i, -LH * 0.3));
            }
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 5 * scale, -LH * 0.3), ptList, ref ext, numErection + "%%C" + erection_reinforcement_diameter + "(t=" + erection_reinforcement_l_spacing + ")", "9", "HM细线", eArrowLocation.LT, scale);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-LT * 0.5, -LH * 0.75));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 5 * scale, -LH * 0.75), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + erection_reinforcement_w_spacing + ")", "10", "HM细线", eArrowLocation.LT, scale, false);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(LT * 0.5, -LH * 0.5));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(LT * 0.5 + 5 * scale, -LH * 0.5), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + erection_reinforcement_w_spacing + ")", "10", "HM细线", eArrowLocation.RT, scale, false);


            SteelBarS.CreateUPRibSection(db, ptTop.C2D(LT * 0.5 + 25 * scale), "3", ref ext, "H文本", scale,true);
            SteelBarS.CreateUPRibSection(db, ptBotom.C2D(LT * 0.5 + 25 * scale,bottom_reinforcement_layers_number*bottom_reinforcement_layers_spacing), "4", ref ext, "H文本", scale, true);
            SteelBarS.CreateUPRibSection(db, ptBotom.C2D(LT * 0.5 + 25 * scale), "5", ref ext, "H文本", scale, false);
            #endregion


        }

        public void CalculateRebar()
        {
            double LT = length - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 + top_l_reinforcement_diameter * 0.1 * 0.5);
            Tuple<int, eSampleType, eDB, int, double> tu;
            int num = 0;
            double len = LT;
            eDB N1 = (eDB)Enum.Parse(typeof(eDB), top_l_reinforcement_diameter.ToString());
            num =(int) ((width - 2 * concrete_protect_layer) / top_w_reinforcement_spacing);
            tu = new Tuple<int, eSampleType, eDB, int, double>(1, eSampleType.UB, N1,  num, len);
            rebarLst.Add(tu);

            eDB N2 = (eDB)Enum.Parse(typeof(eDB), bottom_l_reinforcement_diameter.ToString());
            num = (int)((width - 2 * concrete_protect_layer) / bottom_w_reinforcement_spacing);
            tu = new Tuple<int, eSampleType, eDB, int, double>(2, eSampleType.UT, N2, num, len);
            rebarLst.Add(tu);
          

            len = LT-2;
            eDB N3 = (eDB)Enum.Parse(typeof(eDB), bottom_l_reinforcement_diameter.ToString());
            num = (int)((width - 2 * concrete_protect_layer) / bottom_w_reinforcement_spacing)*2;
            tu = new Tuple<int, eSampleType, eDB, int, double>(3, eSampleType.UN, N3, num, len);
            rebarLst.Add(tu);

            double WT = width - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 + top_l_reinforcement_diameter * 0.1 * 0.5);
            len = WT;
            num = (int)((length - 2 * concrete_protect_layer) / top_l_reinforcement_spacing);
            eDB N4 = (eDB)Enum.Parse(typeof(eDB), top_w_reinforcement_diameter.ToString());
            tu = new Tuple<int, eSampleType, eDB, int, double>(4, eSampleType.UB, N4, num, len);
            rebarLst.Add(tu);

            num = (int)(length/ bottom_w_reinforcement_spacing);
            eDB N5 = (eDB)Enum.Parse(typeof(eDB), bottom_w_reinforcement_diameter.ToString());
            tu = new Tuple<int, eSampleType, eDB, int, double>(5, eSampleType.UT, N5, num, len);
            rebarLst.Add(tu);

            len = WT-2;
            eDB N6 = (eDB)Enum.Parse(typeof(eDB), bottom_w_reinforcement_diameter.ToString());
            tu = new Tuple<int, eSampleType, eDB, int, double>(6, eSampleType.UN, N6, num*2, len);
            rebarLst.Add(tu);


            len = width - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1*0.5);
            num = (int)((height-bottom_reinforcement_layers_number*bottom_reinforcement_layers_spacing- concrete_protect_layer*2) / around_reinforcement_spacing);
            eDB N7 = (eDB)Enum.Parse(typeof(eDB), around_w_reinforcement_diameter.ToString());
            tu = new Tuple<int, eSampleType, eDB, int, double>(7, eSampleType.UB, N7, num*2, len);
            rebarLst.Add(tu);


            eDB N8 = (eDB)Enum.Parse(typeof(eDB), around_l_reinforcement_diameter.ToString());
            len = LT;
            tu = new Tuple<int, eSampleType, eDB, int, double>(8, eSampleType.UB, N8, num*2, len);
            rebarLst.Add(tu);

            len = height - 2 * concrete_protect_layer-1;
            eDB N9 = (eDB)Enum.Parse(typeof(eDB), erection_reinforcement_diameter.ToString());
            int numErection = (int)((height - 2 * concrete_protect_layer) / erection_reinforcement_w_spacing);
            double LTT = length - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5) - around_reinforcement_spacing * 2;
            num = numErection * ((int)(LTT / erection_reinforcement_l_spacing));
            tu = new Tuple<int, eSampleType, eDB, int, double>(9, eSampleType.UBLC, N9, num, len);
            rebarLst.Add(tu);

            len = height - 2 * concrete_protect_layer - erection_reinforcement_diameter*0.1*2 - around_w_reinforcement_diameter*0.1;
            eDB N10 = (eDB)Enum.Parse(typeof(eDB), around_w_reinforcement_diameter.ToString());
            num = (int)((width - 2 * around_reinforcement_spacing) / around_reinforcement_spacing)*2;
            tu = new Tuple<int, eSampleType, eDB, int, double>(10, eSampleType.UR, N10, num, len);
            rebarLst.Add(tu);

            len = height - 2 * concrete_protect_layer - bottom_l_reinforcement_diameter*0.1-top_l_reinforcement_diameter*0.1-erection_reinforcement_diameter * 0.1 * 2-around_l_reinforcement_diameter * 0.1;
            eDB N11 = (eDB)Enum.Parse(typeof(eDB), around_l_reinforcement_diameter.ToString());
            num = (int)((length - 2 * around_reinforcement_spacing) / around_reinforcement_spacing) * 2;
            tu = new Tuple<int, eSampleType, eDB, int, double>(11, eSampleType.UR, N11, num, len);
            rebarLst.Add(tu);
        }
        public void PlotElevationB(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            double LA = 0;
            ext = new Extents2d(insertPoint, insertPoint);
            List<Point2d> ptList = new List<Point2d>();
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -60 * scale);

            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitleS(db,insertPoint, ref ext, "CROSS SECTION 2-2", @"ПОПРЕЧНИ ПРЕСЕК 2-2", "Р/SC 1:" + scale * 10 + "", scale);

            //绘制中心线
            PLPloter.AddScaleLine(db, M1.C2D(0, 50 * scale), M1.C2D(0, -height - 15 * scale), ref ext, "H中心线",scale);
       
            #region  绘制外轮廓
            //墩身
            double pierLen = 160;
            for (int i = 0; i < 1; i++)
            {
                double pSizeLen = double.Parse(pierSize[i].ToString());
                pierLen = pSizeLen + 40;
                double pLen = double.Parse(pierLocation[i].ToString());
                PLPloter.AddPloy4(db, M1.C2D(-0.5 * length + pLen, 40 * scale), 0.5 * pSizeLen, 0.5 * pSizeLen, 40 * scale, ref ext, "HM细线");
                PLPloter.AddLine(db,M1.C2D(-0.5 * length + pLen - pierLen * 0.5, 40 * scale), M1.C2D(-0.5 * length + pLen + pierLen * 0.5, 40 * scale), ref ext, "HM细线");

                //墩柱直径标准
                DimPloter.DimAli(db,M1.C3D(-0.5 * length + pLen - pSizeLen * 0.5, 30 * scale), M1.C3D(-0.5 * length + pLen + pSizeLen * 0.5, 30 * scale), M1.C3D(0, 35 * scale), ref ext, scale, "D" + pSizeLen, Unit.Centimeter, Unit.Centimeter);
            }
            //承台
            PLPloter.AddPloy4(db, M1, 0.5 * width, 0.5 * width, height, ref ext, "HM细线");
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * width), M1.C3D(0.5 * width), M1.C3D(0, 20 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * width), M1.C3D(-0.5 * width, -height), M1.C3D(-0.5 * width - 20 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);

            //PLPloter.AddPloy4(M1.C2D(0, -concrete_protect_layer), 0.5 * (width - concrete_protect_layer * 2), 0.5 * (width - concrete_protect_layer * 2), height - concrete_protect_layer * 2, ref ext, "H钢筋");
            //垫层&&桩基
            Point2d pCushionLeft = M1.C2D(-0.5 * width, -height);
            Point2d pCushionRight = M1.C2D(0.5 * width, -height);
            List<Point2d> middleL = new List<Point2d>();
            if (pileLocation.Length > 0)
            {
                for (int i = 0; i < 1; i++)
                {
                    List<Point2d> leftL = new List<Point2d>();
                    leftL.Add(pCushionLeft);
                    leftL.Add(pCushionLeft.C2D(-cushion_cornice_length));
                    leftL.Add(pCushionLeft.C2D(-cushion_cornice_length, -cushion_thickness));
                    List<Point2d> rightL = new List<Point2d>();
                    rightL.Add(pCushionRight);
                    rightL.Add(pCushionRight.C2D(cushion_cornice_length));
                    rightL.Add(pCushionRight.C2D(cushion_cornice_length, -cushion_thickness));
                    if (i == 0)
                    {
                        leftL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                        //middleL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                        rightL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                        //middleL.Add(pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -cushion_thickness));
                    }

                    //垫层
                    PLPloter.AddPolylineByPointList(db, leftL, ref ext, "HM细线", false);
                    PLPloter.AddPolylineByPointList(db, rightL, ref ext, "HM细线", false);

                    //桩基
                    PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, 0), pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -60 * scale), ref ext, "HM细线");
                    PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, 0), pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -60 * scale), ref ext, "HM细线");

                    PLPloter.AddUpperArcBreakLine(db, pCushionLeft.C2D(double.Parse(pileLocation[i]), -60 * scale), ref ext, double.Parse(pileSize[i]), "HM细线");
                    PLPloter.AddBottomArcBreakLine(db, pCushionLeft.C2D(double.Parse(pileLocation[i]), -70 * scale), ref ext, double.Parse(pileSize[i]), "HM细线");

                    PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -70 * scale), pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -100 * scale), ref ext, "HM细线");
                    PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -70 * scale), pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -100 * scale), ref ext, "HM细线");
                    PLPloter.AddLine(db,pCushionLeft.C2D(double.Parse(pileLocation[i]) - double.Parse(pileSize[i]) * 0.5, -100 * scale), pCushionLeft.C2D(double.Parse(pileLocation[i]) + double.Parse(pileSize[i]) * 0.5, -100 * scale), ref ext, "HM细线");

                }
            }
          
            #endregion

            #region 绘制钢筋
            //1# 20 ,4# 20 top   
            //2# 32 5# 20   3# 32   6# 20 bottom
            //1、顶部钢筋
            double tL = erection_reinforcement_diameter * 0.1 +  top_l_reinforcement_diameter * 0.1 + top_w_reinforcement_diameter * 0.1 * 0.5;
            double bL = erection_reinforcement_diameter * 0.1 + bottom_l_reinforcement_diameter * 0.1  + bottom_w_reinforcement_diameter * 0.1 * 0.5;
            Point2d ptTop = M1.C2D(0, -concrete_protect_layer - tL);
            double LT = width - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 + top_l_reinforcement_diameter * 0.1 * 0.5);
            double LH = Math.Round(height - concrete_protect_layer * 2 - tL - bL, 1);
            double diaX = around_w_reinforcement_diameter * 0.1 + top_l_reinforcement_diameter * 0.1 * 0.5;
            double diaY = top_l_reinforcement_diameter * 0.1 * 0.5 + top_w_reinforcement_diameter * 0.1 * 0.5;
            PLPloter.AddPloy4(db, ptTop.C2D(), 0.5 * LT, 0.5 * LT, LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptTop.C2D(-LT * 0.5), radius, width - 2 * concrete_protect_layer, LT, top_w_reinforcement_spacing, diaX, diaY, out ptLst, eDirection.E_TOP);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLst, eDirection.E_TOP, 15 * scale, "HM细线");
            Point3d pttxtT14 = GeTools.MidPoint(ptLst[0], ptLst[ptLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtT14.C3D(-10 * scale, 15 * scale + 2.5 * scale), ref ext, ptLst.Count + "%%C" + top_l_reinforcement_diameter + "(t=" + top_l_reinforcement_spacing + ")", "1", scale);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-20.5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-20.5 * scale, 5 * scale), ptList, ref ext, "%%C" + top_w_reinforcement_diameter + "(t=" + top_w_reinforcement_spacing + ")", "4", "HM细线", eArrowLocation.TT, scale, false);


            //2、底部钢筋
            Point2d ptBotom = ptTop.C2D(0, -LH);

            double diaBX = around_w_reinforcement_diameter * 0.1 + bottom_l_reinforcement_diameter * 0.1 * 0.5;
            double diaBY = bottom_l_reinforcement_diameter * 0.1 * 0.5 + bottom_w_reinforcement_diameter * 0.1 * 0.5;

            List<Point3d> ptBLst = new List<Point3d>();
            List<Point3d> ptB56Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, width - 2 * concrete_protect_layer, LT, bottom_l_reinforcement_spacing, diaBX, diaBY, out ptBLst, eDirection.E_BOTTOM);
            SteelBarPileCap.CreateLineList(db, ref ext, ptBLst, eDirection.E_BOTTOM, 5 * scale * (bottom_reinforcement_layers_number - 1) + 20 * scale + 15 * scale, "HM细线");
            Point3d pttxtB25 = GeTools.MidPoint(ptBLst[0], ptBLst[ptBLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtB25.C3D(-10 * scale, -(5 * scale * (bottom_reinforcement_layers_number - 1) + 20 * scale + 15 * scale) - 2.5 * scale), ref ext, ptBLst.Count + "%%C" + bottom_l_reinforcement_diameter + "(t=" + bottom_l_reinforcement_spacing + ")", "2", scale);
            ptList = new List<Point2d>();
            if (bottom_reinforcement_layers_number > 1)
            {
                for (int i = 1; i < bottom_reinforcement_layers_number; i++)
                {
                    PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, bottom_reinforcement_layers_spacing * i), ptBotom.C2D(LT * 0.5 - 1, bottom_reinforcement_layers_spacing * i), ref ext, "H钢筋");
                    SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5, bottom_reinforcement_layers_spacing * i), radius, width - 2 * concrete_protect_layer, LT, bottom_l_reinforcement_spacing, diaBX, diaBY, out ptB56Lst, eDirection.E_BOTTOM);
                    SteelBarPileCap.CreateLineList(db, ref ext, ptB56Lst, eDirection.E_BOTTOM, bottom_reinforcement_layers_spacing * i + 20 * scale + 5 * scale * i, "HM细线");
                    ptList.Add(ptBotom.C2D(5 * scale, bottom_reinforcement_layers_spacing * i));
                }
                Point3d pttxtB36 = GeTools.MidPoint(ptB56Lst[0], ptB56Lst[ptB56Lst.Count - 1]);
                TextPloter.AddDBTextWithCirle(db,pttxtB36.C3D(-10*scale, -(bottom_reinforcement_layers_spacing * (bottom_reinforcement_layers_number - 1) + 20 * scale + 5 * scale * (bottom_reinforcement_layers_number - 1)) - 2.5 * scale), ref ext, ptB56Lst.Count * 2 + "%%C" + bottom_l_reinforcement_diameter + "(t=" + bottom_l_reinforcement_spacing + ")", "3", scale);

            }

            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(5 * scale, -8 * scale), ptList, ref ext, "%%C" + bottom_w_reinforcement_diameter + "(t=" + bottom_w_reinforcement_spacing + ")", "6", "HM细线", eArrowLocation.BT, scale, false);
            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-15.5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(-15.5 * scale, -8 * scale), ptList, ref ext, "%%C" + bottom_w_reinforcement_diameter + "(t=" + bottom_w_reinforcement_spacing + ")", "5", "HM细线", eArrowLocation.BT, scale, false);


            //3、侧面钢筋
            Point2d ptLeft = ptBotom.C2D(0, bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number);

            //左侧
            double diaAX = around_w_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            double diaAY = 0;
            double HL = LH - bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number;

            List<Point3d> ptB78Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptLeft.C2D(-LT * 0.5), radius, height - 2 * concrete_protect_layer - bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number, HL, around_reinforcement_spacing, diaAX, diaAY, out ptB78Lst, eDirection.E_LEFT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptB78Lst, eDirection.E_LEFT, 15 * scale, "HM细线");
            Point3d pttxtB78 = GeTools.MidPoint(ptB78Lst[0], ptB78Lst[ptB78Lst.Count - 1]);
            List<string> lstCi = new List<string>() { "7", "8" };
            TextPloter.AddDBTextWithListCirle(db,pttxtB78.C3D(-15 * scale - 2.5 * scale, -10 * scale), ref ext, ptB78Lst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", lstCi, scale, 2.5, GeTools.DegreeToRadian(90));

            Point2d ptRight = ptLeft.C2D(LT * 0.5);
            List<Point3d> ptB87Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight, radius, height - 2 * concrete_protect_layer - bottom_reinforcement_layers_spacing * bottom_reinforcement_layers_number, HL, around_reinforcement_spacing, diaAX, diaAY, out ptB87Lst, eDirection.E_RIGHT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptB87Lst, eDirection.E_RIGHT, 15 * scale, "HM细线");
            Point3d pttxtB87 = GeTools.MidPoint(ptB87Lst[0], ptB87Lst[ptB87Lst.Count - 1]);

         
            TextPloter.AddDBTextWithListCirle(db,pttxtB87.C3D(15 * scale + 2.5 * scale, -10 * scale), ref ext, ptB87Lst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", lstCi, scale, 2.5, GeTools.DegreeToRadian(90));

            ptList = new List<Point2d>();
            //侧面竖立方向
            int numErection = (int)(LT / erection_reinforcement_w_spacing);
            for (int i = 1; i <= numErection; i++)
            {
                //PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + erection_reinforcement_w_spacing * i, erection_reinforcement_diameter * 0.1), ptBotom.C2D(-LT * 0.5 + erection_reinforcement_w_spacing * i, -erection_reinforcement_diameter * 0.1), ref ext, "H钢筋");
                SteelBarPileCap.AddLineSample(ptTop.C2D(-LT * 0.5 + erection_reinforcement_w_spacing * i, erection_reinforcement_diameter * 0.1 + top_l_reinforcement_diameter * 0.1), ptBotom.C2D(-LT * 0.5 + erection_reinforcement_w_spacing * i, -erection_reinforcement_diameter * 0.1 - bottom_l_reinforcement_diameter * 0.1), ref ext, "H钢筋",eSampleType.UBC);
                ptList.Add(ptTop.C2D(-LT * 0.5 + erection_reinforcement_w_spacing * i, -LH*0.3));
            }
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 5 * scale, -LH * 0.3), ptList, ref ext, numErection + "%%C" + erection_reinforcement_diameter + "(t=" + erection_reinforcement_w_spacing + ")", "9","HM细线", eArrowLocation.LT,scale);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-LT * 0.5, -LH * 0.75));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 5 * scale, -LH * 0.75), ptList, ref ext,  "%%C" + around_w_reinforcement_diameter + "(t=" + erection_reinforcement_w_spacing + ")", "11", "HM细线", eArrowLocation.LT, scale,false);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(LT * 0.5, -LH * 0.5));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(LT * 0.5 + 5 * scale, -LH * 0.5), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + erection_reinforcement_w_spacing + ")", "11", "HM细线", eArrowLocation.RT, scale, false);

            #endregion
        }

        public void PlotElevationC(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            double LA = 0;
            ext = new Extents2d(insertPoint, insertPoint);
            List<Point2d> ptList = new List<Point2d>();

            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -40 * scale);
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitleS(db,insertPoint, ref ext, "CROSS SECTION 3-3", @"ПОПРЕЧНИ ПРЕСЕК 3-3", "Р/SC 1:" + scale * 10 + "", scale);
            #region  绘制外轮廓
            PLPloter.AddPloy4(db, M1, 0.5 * length, 0.5 * length, width, ref ext, "HM细线");
            for (int i = 0; i < pierLocation.Length; i++)
            {
                double pSizeLen = double.Parse(pierSize[i].ToString());
                double pLen = double.Parse(pierLocation[i].ToString());

                PLPloter.AddCircle(db, M1.C2D(-0.5 * length + pLen,-width*0.5), pSizeLen*0.5,ref ext, "H虚线", scale);
            }
            for (int i = 0; i < pileLocation.Length; i++)
            {
                double pSizeLen = double.Parse(pileSize[i].ToString());
                double pLen = double.Parse(pileLocation[i].ToString());

                PLPloter.AddCircle(db, M1.C2D(-0.5 * length + pLen,-width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
            }
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(0.5 * length), M1.C3D(0, 25 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(-0.5 * length, -width), M1.C3D(0.5 * length + 25 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            #endregion

            #region  绘制钢筋


            Point2d ptTop = M1.C2D(0, -concrete_protect_layer);
            double LT = length - 2 * (concrete_protect_layer + around_l_reinforcement_diameter * 0.1 * 0.5);
            double LH = width - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5); ;
            double diaX = around_w_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            double diaY = around_l_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            PLPloter.AddPloy4(db, ptTop.C2D(), 0.5 * LT, 0.5 * LT, LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptTop.C2D(-LT * 0.5), radius, length, LT, around_reinforcement_spacing, diaX, diaY, out ptLst, eDirection.E_BOTTOM);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLst, eDirection.E_TOP, 15 * scale, "HM细线");
            Point3d pttxtT11 = GeTools.MidPoint(ptLst[0], ptLst[ptLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtT11.C3D(-10 * scale, 15 * scale + 2.5 * scale), ref ext, ptLst.Count + "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "11", scale);



            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-5 * scale, 5 * scale), ptList, ref ext, "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "8", "HM细线", eArrowLocation.TT, scale, false);

            ptList = new List<Point2d>();
            double h1H = LH * 0.6;
            ptList.Add(ptTop.C2D(-LT * 0.5 + diaX * 2,-h1H));
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 ) * around_reinforcement_spacing + diaX * 2,-diaY ), ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 ) * around_reinforcement_spacing + diaX * 2,-LH+ diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 +1) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 ) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 ) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 ) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 ) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(LT * 0.5 - diaX * 2, -h1H));
            SteelBarPileCap.AddLineBothArrowDim(db, ptTop.C2D(-LT * 0.5 - 8 * scale, -h1H), ptList, ref ext, (int)((length - 2 * concrete_protect_layer) / top_l_reinforcement_spacing) + "%%C" + top_l_reinforcement_diameter + "(t=" + top_l_reinforcement_spacing + ")", "1", "HM细线", eArrowLocation.LB, scale, false);


            Point2d ptBotom = ptTop.C2D(0, -LH);
            List<Point3d> ptBLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, length, LT, around_reinforcement_spacing, diaX, diaY, out ptBLst, eDirection.E_TOP);
            SteelBarPileCap.CreateLineList(db, ref ext, ptBLst, eDirection.E_BOTTOM, 15 * scale, "HM细线");
            Point3d pttxtB11= GeTools.MidPoint(ptBLst[0], ptBLst[ptBLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtB11.C3D(-10 * scale, -15 * scale - 2.5 * scale), ref ext, ptLst.Count + "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "11", scale);

            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(-5 * scale, -8 * scale), ptList, ref ext, "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "8", "HM细线", eArrowLocation.BT, scale, false);


            Point2d ptLeft = ptBotom.C2D(0, around_reinforcement_spacing);
            double LTA = width - 2 * (concrete_protect_layer + around_l_reinforcement_diameter * 0.1 * 0.5)-around_reinforcement_spacing*2;
            List<Point3d> ptLLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptLeft.C2D(-LT * 0.5), radius, width-2*around_reinforcement_spacing, LTA, around_reinforcement_spacing, -diaX, diaY, out ptLLst, eDirection.E_LEFT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLLst, eDirection.E_LEFT, 15 * scale, "HM细线");
            Point3d pttxtL10 = GeTools.MidPoint(ptLLst[0], ptLLst[ptLLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtL10.C3D(-15 * scale - 2.5 * scale, -10 * scale), ref ext, ptLLst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "10", scale,2.5,GeTools.DegreeToRadian(90));


            Point2d ptRight = ptBotom.C2D(0, around_reinforcement_spacing);
          
            List<Point3d> ptRLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight.C2D(LT * 0.5), radius, width - 2 * around_reinforcement_spacing, LTA, around_reinforcement_spacing, -diaX, diaY, out ptRLst, eDirection.E_RIGHT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptRLst, eDirection.E_RIGHT, 15 * scale, "HM细线");
            Point3d pttxtR10 = GeTools.MidPoint(ptRLst[0], ptRLst[ptRLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtR10.C3D(15 * scale + 2.5 * scale, -10 * scale), ref ext, ptRLst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "10", scale, 2.5, GeTools.DegreeToRadian(90));

            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-LT * 0.5* 0.8, diaY * 2));
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count*2 / 3 + 1) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count * 2 / 3 +2) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count * 2 / 3 + 2) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptTop.C2D(-LT * 0.5 * 0.8, -diaY * 2));
            SteelBarPileCap.AddLineBothArrowDim(db, ptBotom.C2D(-LT * 0.5 * 0.8, -8*scale), ptList, ref ext,(int)( (width - 2 * concrete_protect_layer)/top_w_reinforcement_spacing)+ "%%C" + top_w_reinforcement_diameter + "(t=" + top_w_reinforcement_spacing + ")", "4", "HM细线", eArrowLocation.BT, scale, false);



            double LTT = length - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5) - around_reinforcement_spacing * 2;
            int numErection = (int)(LH / erection_reinforcement_w_spacing);
            for(int i=1;i<= numErection;i++)
            {
                List<Point3d> ptALst = new List<Point3d>();
                SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5+ erection_reinforcement_l_spacing, erection_reinforcement_w_spacing*i), radius, length - 2 * around_reinforcement_spacing, LTT, erection_reinforcement_l_spacing, diaX, diaY, out ptALst, eDirection.E_TOP);
            }

        

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-LT * 0.5, -LH * 0.15));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 8 * scale, -LH * 0.15), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "7", "HM细线", eArrowLocation.LB, scale, false);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(LT * 0.5, -LH * 0.15));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(LT * 0.5 + 10 * scale, -LH * 0.15), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "7", "HM细线", eArrowLocation.RB, scale, false);


            SteelBarS.CreateRibSection(db, ptTop.C2D(0, 22 * scale), "2", ref ext, "H文本", scale,false);
            SteelBarS.CreateRibSection(db, ptBotom.C2D(0, -22* scale), "2", ref ext, "H文本", scale, false);
            #endregion

        }

        public void PlotElevationD(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            double LA = 0;
            ext = new Extents2d(insertPoint, insertPoint);
            List<Point2d> ptList = new List<Point2d>();

            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -40 * scale);
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitleS(db,insertPoint, ref ext, "CROSS SECTION 4-4", @"ПОПРЕЧНИ ПРЕСЕК 4-4", "Р/SC 1:" + scale * 10 + "", scale);
            #region  绘制外轮廓
            PLPloter.AddPloy4(db, M1, 0.5 * length, 0.5 * length, width, ref ext, "HM细线");
            for (int i = 0; i < pierLocation.Length; i++)
            {
                double pSizeLen = double.Parse(pierSize[i].ToString());
                double pLen = double.Parse(pierLocation[i].ToString());

                PLPloter.AddCircle(db, M1.C2D(-0.5 * length + pLen, -width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
            }
            for (int i = 0; i < pileLocation.Length; i++)
            {
                double pSizeLen = double.Parse(pileSize[i].ToString());
                double pLen = double.Parse(pileLocation[i].ToString());

                PLPloter.AddCircle(db, M1.C2D(-0.5 * length + pLen, -width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
            }
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(0.5 * length), M1.C3D(0, 25 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(-0.5 * length, -width), M1.C3D(0.5 * length + 25 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            #endregion

            #region  绘制钢筋


            Point2d ptTop = M1.C2D(0, -concrete_protect_layer);
            double LT = length - 2 * (concrete_protect_layer + around_l_reinforcement_diameter * 0.1 * 0.5);
            double LH = width - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5); ;
            double diaX = around_w_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            double diaY = around_l_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            PLPloter.AddPloy4(db, ptTop.C2D(), 0.5 * LT, 0.5 * LT, LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptTop.C2D(-LT * 0.5), radius, length, LT, around_reinforcement_spacing, diaX, diaY, out ptLst, eDirection.E_BOTTOM);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLst, eDirection.E_TOP, 15 * scale, "HM细线");
            Point3d pttxtT11 = GeTools.MidPoint(ptLst[0], ptLst[ptLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtT11.C3D(-10 * scale, 15 * scale + 2.5 * scale), ref ext, ptLst.Count + "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "11", scale);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-5 * scale, 5 * scale), ptList, ref ext, "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "8", "HM细线", eArrowLocation.TT, scale, false);

            ptList = new List<Point2d>();
            double h1H = LH * 0.6;
            ptList.Add(ptTop.C2D(-LT * 0.5 + diaX * 2, -h1H));
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6) * around_reinforcement_spacing + diaX * 2, -diaY), ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(LT * 0.5 - diaX * 2, -h1H));
            SteelBarPileCap.AddLineBothArrowDim(db, ptTop.C2D(-LT * 0.5 - 8 * scale, -h1H), ptList, ref ext, (int)((length - 2 * concrete_protect_layer) / top_l_reinforcement_spacing) + "%%C" + top_l_reinforcement_diameter + "(t=" + top_l_reinforcement_spacing + ")", "1", "HM细线", eArrowLocation.LB, scale, false);

            Point2d ptBotom = ptTop.C2D(0, -LH);
            List<Point3d> ptBLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, length, LT, around_reinforcement_spacing, diaX, diaY, out ptBLst, eDirection.E_TOP);
            SteelBarPileCap.CreateLineList(db, ref ext, ptBLst, eDirection.E_BOTTOM, 15 * scale, "HM细线");
            Point3d pttxtB11 = GeTools.MidPoint(ptBLst[0], ptBLst[ptBLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtB11.C3D(-10 * scale, -15 * scale - 2.5 * scale), ref ext, ptLst.Count + "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "11", scale);

            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(-5 * scale, -8 * scale), ptList, ref ext, "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "8", "HM细线", eArrowLocation.BT, scale, false);


            Point2d ptLeft = ptBotom.C2D(0, around_reinforcement_spacing);
            double LTA = width - 2 * (concrete_protect_layer + around_l_reinforcement_diameter * 0.1 * 0.5) - around_reinforcement_spacing * 2;
            List<Point3d> ptLLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptLeft.C2D(-LT * 0.5), radius, width - 2 * around_reinforcement_spacing, LTA, around_reinforcement_spacing, -diaX, diaY, out ptLLst, eDirection.E_LEFT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLLst, eDirection.E_LEFT, 15 * scale, "HM细线");
            Point3d pttxtL10 = GeTools.MidPoint(ptLLst[0], ptLLst[ptLLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtL10.C3D(-15 * scale - 2.5 * scale, -10 * scale), ref ext, ptLLst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "10", scale, 2.5, GeTools.DegreeToRadian(90));


            Point2d ptRight = ptBotom.C2D(0, around_reinforcement_spacing);

            List<Point3d> ptRLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight.C2D(LT * 0.5), radius, width - 2 * around_reinforcement_spacing, LTA, around_reinforcement_spacing, -diaX, diaY, out ptRLst, eDirection.E_RIGHT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptRLst, eDirection.E_RIGHT, 15 * scale, "HM细线");
            Point3d pttxtR10 = GeTools.MidPoint(ptRLst[0], ptRLst[ptRLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtR10.C3D(15 * scale + 2.5 * scale, -10 * scale), ref ext, ptRLst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "10", scale, 2.5, GeTools.DegreeToRadian(90));

            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, diaY * 2));
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count * 2 / 3 + 2) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count * 2 / 3 + 2) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptTop.C2D(-LT * 0.5 * 0.8, -diaY * 2));
            SteelBarPileCap.AddLineBothArrowDim(db, ptBotom.C2D(-LT * 0.5 * 0.8, -8 * scale), ptList, ref ext, (int)((width - 2 * concrete_protect_layer) / top_w_reinforcement_spacing) + "%%C" + top_w_reinforcement_diameter + "(t=" + top_w_reinforcement_spacing + ")", "4", "HM细线", eArrowLocation.BT, scale, false);


            double LTT = length - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5) - around_reinforcement_spacing * 2;
            int numErection = (int)(LH / erection_reinforcement_w_spacing);
            for (int i = 1; i <= numErection; i++)
            {
                List<Point3d> ptALst = new List<Point3d>();
                SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5 + erection_reinforcement_l_spacing, erection_reinforcement_w_spacing * i), radius, length - 2 * around_reinforcement_spacing, LTT, erection_reinforcement_l_spacing, diaX, diaY, out ptALst, eDirection.E_TOP);
            }


            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-LT * 0.5, -LH * 0.15));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 8 * scale, -LH * 0.15), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "7", "HM细线", eArrowLocation.LB, scale, false);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(LT * 0.5, -LH * 0.15));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(LT * 0.5 + 10 * scale, -LH * 0.15), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "7", "HM细线", eArrowLocation.RB, scale, false);


            SteelBarS.CreateRibSection(db, ptTop.C2D(0, 22 * scale), "2", ref ext, "H文本", scale, false);
            SteelBarS.CreateRibSection(db, ptBotom.C2D(0, -22 * scale), "2", ref ext, "H文本", scale, false);
            #endregion

        }

        public void PlotElevationE(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            double LA = 0;
            ext = new Extents2d(insertPoint, insertPoint);
            List<Point2d> ptList = new List<Point2d>();

            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -40 * scale);
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitleS(db,insertPoint, ref ext, "CROSS SECTION 5-5", @"ПОПРЕЧНИ ПРЕСЕК 5-5", "Р/SC 1:" + scale * 10 + "", scale);
            #region  绘制外轮廓
            PLPloter.AddPloy4(db, M1, 0.5 * length, 0.5 * length, width, ref ext, "HM细线");
            for (int i = 0; i < pierLocation.Length; i++)
            {
                double pSizeLen = double.Parse(pierSize[i].ToString());
                double pLen = double.Parse(pierLocation[i].ToString());

                PLPloter.AddCircle(db, M1.C2D(-0.5 * length + pLen, -width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
            }
            for (int i = 0; i < pileLocation.Length; i++)
            {
                double pSizeLen = double.Parse(pileSize[i].ToString());
                double pLen = double.Parse(pileLocation[i].ToString());

                PLPloter.AddCircle(db, M1.C2D(-0.5 * length + pLen, -width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
            }
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(0.5 * length), M1.C3D(0, 25 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * length), M1.C3D(-0.5 * length, -width), M1.C3D(0.5 * length + 25 * scale), ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            #endregion

            #region  绘制钢筋


            Point2d ptTop = M1.C2D(0, -concrete_protect_layer);
            double LT = length - 2 * (concrete_protect_layer + around_l_reinforcement_diameter * 0.1 * 0.5);
            double LH = width - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5); ;
            double diaX = around_w_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            double diaY = around_l_reinforcement_diameter * 0.1 * 0.5 + around_h_reinforcement_diameter * 0.1 * 0.5;
            PLPloter.AddPloy4(db, ptTop.C2D(), 0.5 * LT, 0.5 * LT, LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptTop.C2D(-LT * 0.5), radius, length, LT, around_reinforcement_spacing, diaX, diaY, out ptLst, eDirection.E_BOTTOM);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLst, eDirection.E_TOP, 15 * scale, "HM细线");
            Point3d pttxtT11 = GeTools.MidPoint(ptLst[0], ptLst[ptLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtT11.C3D(-10 * scale, 15 * scale + 2.5 * scale), ref ext, ptLst.Count + "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "11", scale);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-5 * scale, 5 * scale), ptList, ref ext, "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "8", "HM细线", eArrowLocation.TT, scale, false);

            ptList = new List<Point2d>();
            double h1H = LH * 0.6;
            ptList.Add(ptTop.C2D(-LT * 0.5 + diaX * 2, -h1H));
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6) * around_reinforcement_spacing + diaX * 2, -diaY), ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2), ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2, -LH + diaY), ref ext, "H钢筋");
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count / 6 + 1) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(-LT * 0.5 + (ptLst.Count * 5 / 6 + 1) * around_reinforcement_spacing + diaX * 2, -h1H));
            ptList.Add(ptTop.C2D(LT * 0.5 - diaX * 2, -h1H));
            SteelBarPileCap.AddLineBothArrowDim(db, ptTop.C2D(-LT * 0.5 - 8 * scale, -h1H), ptList, ref ext, (int)((length - 2 * concrete_protect_layer) / bottom_l_reinforcement_spacing) + "%%C" + bottom_l_reinforcement_diameter + "(t=" + bottom_l_reinforcement_spacing + ")", "2", "HM细线", eArrowLocation.LB, scale, false);


            Point2d ptBotom = ptTop.C2D(0, -LH);
            List<Point3d> ptBLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, length, LT, around_reinforcement_spacing, diaX, diaY, out ptBLst, eDirection.E_TOP);
            SteelBarPileCap.CreateLineList(db, ref ext, ptBLst, eDirection.E_BOTTOM, 15 * scale, "HM细线");
            Point3d pttxtB11 = GeTools.MidPoint(ptBLst[0], ptBLst[ptBLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtB11.C3D(-10 * scale, -15 * scale - 2.5 * scale), ref ext, ptLst.Count + "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "11", scale);

            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-5 * scale, 0));
            SteelBarPileCap.AddLineArrowDim(db, ptBotom.C2D(-5 * scale, -8 * scale), ptList, ref ext, "%%C" + around_l_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "8", "HM细线", eArrowLocation.BT, scale, false);



            Point2d ptLeft = ptBotom.C2D(0, around_reinforcement_spacing);
            double LTA = width - 2 * (concrete_protect_layer + around_l_reinforcement_diameter * 0.1 * 0.5) - around_reinforcement_spacing * 2;
            List<Point3d> ptLLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptLeft.C2D(-LT * 0.5), radius, width - 2 * around_reinforcement_spacing, LTA, around_reinforcement_spacing, -diaX, diaY, out ptLLst, eDirection.E_LEFT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptLLst, eDirection.E_LEFT, 15 * scale, "HM细线");
            Point3d pttxtL10 = GeTools.MidPoint(ptLLst[0], ptLLst[ptLLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtL10.C3D(-15 * scale - 2.5 * scale, -10 * scale), ref ext, ptLLst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "10", scale, 2.5, GeTools.DegreeToRadian(90));


            Point2d ptRight = ptBotom.C2D(0, around_reinforcement_spacing);

            List<Point3d> ptRLst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight.C2D(LT * 0.5), radius, width - 2 * around_reinforcement_spacing, LTA, around_reinforcement_spacing, -diaX, diaY, out ptRLst, eDirection.E_RIGHT);
            SteelBarPileCap.CreateLineList(db, ref ext, ptRLst, eDirection.E_RIGHT, 15 * scale, "HM细线");
            Point3d pttxtR10 = GeTools.MidPoint(ptRLst[0], ptRLst[ptRLst.Count - 1]);
            TextPloter.AddDBTextWithCirle(db,pttxtR10.C3D(15 * scale + 2.5 * scale, -10 * scale), ref ext, ptRLst.Count + "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "10", scale, 2.5, GeTools.DegreeToRadian(90));

            ptList = new List<Point2d>();
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, diaY * 2));
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            PLPloter.AddLine(db,ptBotom.C2D(-LT * 0.5 + 1, (ptLLst.Count * 2 / 3 + 2) * around_reinforcement_spacing + diaY * 2), ptBotom.C2D(LT * 0.5 - 1, (ptLLst.Count * 2 / 3 + 2) * around_reinforcement_spacing + diaY * 2), ref ext, "H钢筋");
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count / 3 - 2) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count / 3 - 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptBotom.C2D(-LT * 0.5 * 0.8, (ptLLst.Count * 2 / 3 + 1) * around_reinforcement_spacing + diaY * 2));
            ptList.Add(ptTop.C2D(-LT * 0.5 * 0.8, -diaY * 2));
            SteelBarPileCap.AddLineBothArrowDim(db, ptBotom.C2D(-LT * 0.5 * 0.8, -8 * scale), ptList, ref ext, (int)((width - 2 * concrete_protect_layer) / bottom_w_reinforcement_spacing) + "%%C" + bottom_w_reinforcement_diameter + "(t=" + bottom_w_reinforcement_spacing + ")", "5", "HM细线", eArrowLocation.BT, scale, false);


            double LTT = length - 2 * (concrete_protect_layer + around_w_reinforcement_diameter * 0.1 * 0.5) - around_reinforcement_spacing * 2;
            int numErection = (int)(LH / erection_reinforcement_w_spacing);
            for (int i = 1; i <= numErection; i++)
            {
                List<Point3d> ptALst = new List<Point3d>();
                SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5 + erection_reinforcement_l_spacing, erection_reinforcement_w_spacing * i), radius, length - 2 * around_reinforcement_spacing, LTT, erection_reinforcement_l_spacing, diaX, diaY, out ptALst, eDirection.E_TOP);
            }

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(-LT * 0.5, -LH * 0.15));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(-LT * 0.5 - 8 * scale, -LH * 0.15), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "7", "HM细线", eArrowLocation.LB, scale, false);

            ptList = new List<Point2d>();
            ptList.Add(ptTop.C2D(LT * 0.5, -LH * 0.15));
            SteelBarPileCap.AddLineArrowDim(db, ptTop.C2D(LT * 0.5 + 10 * scale, -LH * 0.15), ptList, ref ext, "%%C" + around_w_reinforcement_diameter + "(t=" + around_reinforcement_spacing + ")", "7", "HM细线", eArrowLocation.RB, scale, false);


            SteelBarS.CreateRibSection(db, ptTop.C2D(0, 22 * scale), "2", ref ext, "H文本", scale, false);
            SteelBarS.CreateRibSection(db, ptBotom.C2D(0, -22 * scale), "2", ref ext, "H文本", scale, false);
            #endregion

        }
    }

}
